package cn.uppower.wordaliy;

import android.app.Application;
import android.content.SharedPreferences;
import android.util.Log;

import org.litepal.LitePal;

import cn.uppower.wordaliy.model.UserInfo;
import cn.uppower.wordaliy.model.Words;

/**
 * Created by elitetyc on 2018/11/26.
 * Describe:
 */
public class WordaliyApplication extends Application {
    public static SharedPreferences wordaliySharedPreferences;
    public static SharedPreferences.Editor wordaliyEditor;
    public static UserInfo userInfo;
    @Override
    public void onCreate() {
        super.onCreate();
//        初始化数据库工具
        LitePal.initialize(this);

        wordaliySharedPreferences=getSharedPreferences("userinfo",MODE_PRIVATE);
        wordaliyEditor=wordaliySharedPreferences.edit();
        userInfo=new UserInfo();
        userInfo.setUserPhone(wordaliySharedPreferences.getString("userPhone",null));
        userInfo.setRegisteTime(wordaliySharedPreferences.getString("registeTime",null));


        boolean isFirstInstall = wordaliySharedPreferences.getBoolean("isFirstInstall",true);
        if (isFirstInstall){
            new Words("absorb","vt.吸收;吸引;吞并,合并;","əbˈsɔ:rb",R.drawable.word_absorb,"Plants absorb carbon dioxide\n植物吸收二氧化碳").save();
            new Words("capture","vt.俘获;夺取;夺得;","ˈkæptʃə(r)",R.drawable.word_capture,"The incident was captured on videotape \n事件被拍成了录像").save();
            new Words("virus","n.病毒;病毒性疾病;","ˈvaɪrəs",R.drawable.word_virus,"The virus seems to have attacked his throat \n病毒看来已经侵蚀到他喉部了。").save();
            new Words("wreck","n.毁灭，失事;遇难船的残骸;","rek",R.drawable.word_wreck,"The ship was wrecked by an explosion. \n这艘船被炸毁了").save();
            new Words("accent","n.口音;重音;腔调;","ˈæksent",R.drawable.word_accent,"He had developed a slight American accent. \n他说话带上了一点轻微的美国口音。").save();
            new Words("tame","v.驯服;抑制","teɪm",R.drawable.word_tame,"After all, he's not a tame lion. \n毕竟他不是只驯服了的狮子。").save();
            new Words("resistant","adj.有抵抗力的，抵抗的;顽固的","rɪˈzɪstənt",R.drawable.word_resistant,"The body may be less resistant if it is cold. \n天冷时，身体的抵抗力会下降。").save();
            new Words("undertake","vt.承诺;保证;承担，从事;","ˌʌndəˈteɪk",R.drawable.word_undertake,"She undertook the arduous task of monitoring the elections. \n她承担了监督选举的艰巨任务。").save();
            new Words("deny","vt.拒绝;拒绝承认;","dɪˈnaɪ",R.drawable.word_deny,"She denied both accusations \n她对两项指控均予以否认。").save();
            new Words("crawl","vi.爬行;缓慢行进;","krɔ:l",R.drawable.word_crawl,"I crawled out of bed at nine-thirty \n我9点半才勉强从床上爬起来。").save();
            new Words("mysterious","adj.玄妙;神秘的，诡秘的;","mɪˈstɪəriəs",R.drawable.word_mysterious,"He died in mysterious circumstances \n他死得很蹊跷。").save();
            new Words("prevail","vi.流行，盛行;","prɪˈveɪl",R.drawable.word_prevail,"We hope that common sense would prevail \n我们希望情理会占上风。").save();
            new Words("token","n.象征;记号;","ˈtəʊkən",R.drawable.word_token,"This little gift is a token of our regard. \n这点礼物是我们大家的一点心意。").save();
            new Words("glimpse","n.一瞥，一看;","glɪmps",R.drawable.word_glimpse,"I had a glimpse of his true feelings. \n我窥见到他的真实感情。").save();
            new Words("stripe","n.条纹;种类;","straɪp",R.drawable.word_stripe,"I have a white head, with a black stripe. \n我有一个白色的头，带黑色条纹。").save();
            new Words("visual","adj.视觉的，看得见的;","ˈvɪʒuəl",R.drawable.word_visual,"We work on improving visual acuity. \n我们致力于提高视觉的敏锐度。").save();
            new Words("athlete","n.运动员;体育家;","ˈæθli:t",R.drawable.word_athlete,"I was no athlete. \n我根本不是当运动员的料。").save();
            new Words("flesh","n.肉;肉体;","fleʃ",R.drawable.word_flesh,"Cut the flesh from the olives and discard the stones. \n把橄榄的果肉切下来，然后去除果核。").save();
            new Words("shear","vi.剪切;修剪;","ʃɪə(r)",R.drawable.word_shear,"Trim the shrubs with shears. \n用大剪刀修剪灌木丛。").save();
            new Words("pause","vi.暂停，中止;","pɔ:z",R.drawable.word_pause,"He had to pause to clear his throat \n他不得不停顿一下清清嗓子。").save();
            new Words("challenge","n.挑战，质疑;怀疑;","ˈtʃæləndʒ",R.drawable.word_challenge,"It was ill-prepared to meet this challenge. \n应对这一挑战明显准备不足。").save();
            new Words("hang","vi.悬垂;被吊死","hæŋ",R.drawable.word_hang,"The walls were hung with huge modern paintings. \n墙上挂着巨幅的现代画。").save();
            new Words("reveal","vt.揭露;泄露;显露;","rɪˈvi:l",R.drawable.word_reveal,"I shall not reveal the movie's final reel. \n我不会透露该片的结局。").save();
            new Words("ordinary","adj.普通的;一般的;","ˈɔ:dnri",R.drawable.word_ordinary,"I'm just a very ordinary, boring normal guy \n我只是一个颇为平庸无趣的普通人。").save();
            wordaliyEditor.putBoolean("isFirstInstall",false);
            wordaliyEditor.commit();
        }




//        LitePal.delete(Words.class,1);



    }
}
